package com.yundingai.controller;

import com.yundingai.domain.entity.AllUser;
import com.yundingai.service.AllUserService;
import com.yundingai.service.RoomService;
import com.yundingai.vm.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zhaoj
 * @Date 2025/7/25 09:49
 * @Description 数据控制器提供网站展示用数据的查询API
 **/
@RestController
@RequestMapping("statistic")
public class StatisticController {

    @Autowired
    private AllUserService allUserService;

    @Autowired
    private RoomService roomService;

    /**
     * 获取用户总数
     */
    @GetMapping("totalUserCount")
    public ResponseResult<AllUser> getTotalUsers() {
        return ResponseResult.okResult(allUserService.getTotalUsers());
    }

    @GetMapping("onlineUser")
    public ResponseResult<Integer> getOnlineUsers(){
        return ResponseResult.okResult(roomService.getUserCount());
    }
    @GetMapping("activeRoom")
    public ResponseResult<Integer> getRoomCount(){
        return ResponseResult.okResult(roomService.getRoomCount());
    }
}
